<html>
	<head>
		<meta charset="utf-8"/>
		<link rel="stylesheet" type="text/css" href="css/style.css"/>
		<script type="text/javascript" src="js/index.js"></script>
		<title> 学生成绩管理系统</title>
	</head>
	<body>
		<h1>学生成绩管理系统</h1>
		<table>
			<tr>
				<td>姓名:</td>
				<td><input type="text" name="name"></td>
			</tr>
			<tr>
				<td>年龄:</td>
				<td><input type="text" name="age"></td>
			</tr>
			<tr>
				<td>成绩:</td>
				<td><input type="text" name="result"></td>
			</tr>
			<tr>
				<td colspan="4">
					<button onclick="insert()">添加</button>
			</tr>
		</table>
		<script type="text/javascript">
			function insert(){
				let name =document.getElementsByName("name")[0].value;
				let age =document.getElementsByName("age")[0].value;
				let result =document.getElementsByName("result")[0].value;
				let ajax = getAjax();
				ajax.open("POST","./server/insert_server.php",false);
				ajax.setRequestHeader("content-type","application/x-www-form-urlencoded;charset = UTF-8");
				ajax.send("name=" + name+ "&age=" + age + "&result=" + result);
				alert(ajax.responseText);
				window.location.href = "index.php";
			}
		</script>
	</body>
</html>